import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JFrame;


public class WindowGUI {

	private static int buttons = 50;
	private static boolean fun = false;
	private JFrame buttonframe;
	
	public WindowGUI(){
		initGUI();
	}
	
	private void initGUI(){
		buttonframe = new JFrame(buttons+"-Bu770n2");
		buttonframe.setLayout(new FlowLayout());
		for(int i = 0;i <= buttons;i++){
			JButton b = new JButton("0");
			b.addActionListener(new EventHandler());
			//b.setBackground(new Color((int) Math.round(Math.random()*999999999)));
			buttonframe.add(b);
		}
		buttonframe.setBackground(new Color(80000));
		buttonframe.setBounds(50, 50, 1200, 680);
		buttonframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		buttonframe.setVisible(true);
	}
	
	 private class EventHandler implements ActionListener {
		 public void actionPerformed(ActionEvent e) {
				int number = Integer.parseInt(((AbstractButton) e.getSource()).getText());
				number++;
				if(fun) {
					// Der Apfel macht sowas tolles leider nicht
					((AbstractButton) e.getSource()).setBackground(new Color((int) Math.round(Math.random()*999999999)));
					buttonframe.setBackground(new Color((int) Math.round(Math.random()*999999999)));
				}
				((AbstractButton) e.getSource()).setText(""+number);
			}
	 }
}
